package ontology;

import java.util.List;
import java.util.ArrayList;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * This class is used to parse the 'frame' elements of the FrameNet
 * ontology file (frXML/frames.xml). These elements have the following 
 * format:
 * 
 * frame @name
 *   > fes
 *       > fe*
 *
 */

public class Frame {

	public String name;
	public List<FrameElement> frameElements = new ArrayList<FrameElement>();
	
	public Frame(Element e) {
		name = e.getAttribute("name");
		NodeList ns = e.getChildNodes();
		for (int i=0;i<ns.getLength();i++) {
			Node n = ns.item(i);
			String s = n.getNodeName();
			if (s.equals("fes")) {
				NodeList nns = ((Element) n).getChildNodes();
				for (int j=0;j<nns.getLength();j++) {
					Node nn = nns.item(j);
					String ss = nn.getNodeName();
					if (ss.equals("fe")) {
						frameElements.add(new FrameElement((Element) nn));
					}
				}				
			}
		}
	}
	
}
